/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
package shop.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import shop.dao.BaseDao;
import shop.entity.Payment;

public class PaymentDao extends BaseDao {
	private Connection conn = null;
	private PreparedStatement pstmt = null;
	private ResultSet rs = null;

	public List<Payment> findPayment() {
		ArrayList list = new ArrayList();
		String sql = "select  * from Payment";

		try {
			this.conn = this.getConn();
			this.pstmt = this.conn.prepareStatement(sql);
			this.rs = this.pstmt.executeQuery();

			while (this.rs.next()) {
				Payment e = new Payment();
				e.setPay_id(this.rs.getString("pay_id"));
				e.setPay_msg(this.rs.getString("pay_msg"));
				e.setPay_payment(this.rs.getString("pay_payment"));
				list.add(e);
			}
		} catch (Exception arg6) {
			arg6.printStackTrace();
		} finally {
			this.closeAll(this.conn, this.pstmt, this.rs);
		}

		return list;
	}

	public Payment findPaymentBYPAY(String pay_payment) {
		Payment pt = null;
		String sql = "select  * from Payment where pay_payment=\'" + pay_payment + "\'";

		try {
			this.conn = this.getConn();
			this.pstmt = this.conn.prepareStatement(sql);
			this.rs = this.pstmt.executeQuery();
			if (this.rs.next()) {
				pt = new Payment();
				pt.setPay_id(this.rs.getString("pay_id"));
				pt.setPay_msg(this.rs.getString("pay_msg"));
				pt.setPay_payment(this.rs.getString("pay_payment"));
			}
		} catch (Exception arg7) {
			arg7.printStackTrace();
		} finally {
			this.closeAll(this.conn, this.pstmt, this.rs);
		}

		return pt;
	}
}